﻿using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Core.DatabaseAccess;
using PuroGame.Repositories.Repository;
using PuroGame.Business;
using Microsoft.Practices.Unity;

namespace Teste_Repositorios
{   
    /// <summary>
    /// Summary description for usuario_Teste
    /// </summary>
    [TestClass]
    public class usuario_Teste
    {
       
        public usuario_Teste()
        {
            
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void SALVAR_UM_NOVO_USUARIO()
        {
            usuario _usuario = new usuario();
            _usuario.nome = "Usuario de Teste " + DateTime.Now.Millisecond;
            _usuario.email = "luigicasa@gmail.com";
            _usuario.senha = "senhateste";
            _usuario.ip = "192.168.0.1";


            UsuarioRepository repository = new UsuarioRepository();
            repository.Criar(_usuario);
        }

        [TestMethod]
        public void VERIFICAR_SE_USUARIO_EXISTE()
        {
            usuario _usuario = new usuario();
            _usuario.email = "luigicasa@gmail.com";
            _usuario.senha = "senhateste";

            UsuarioRepository _repositorio = new UsuarioRepository();
            usuario _usuario_logado = _repositorio.Login(_usuario);

            Assert.IsTrue(_usuario_logado != null);
        }
    }
}
